<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>Makes timer event pending</title>

 </head>
 <body><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="event.addsignal.html">Event::addSignal</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="event.construct.html">Event::__construct</a></div>
 <div class="up"><a href="class.event.html">Event</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div><hr /><div id="event.addtimer" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">Event::addTimer</h1>
  <p class="verinfo">(PECL event &gt;= 1.2.6-beta)</p><p class="refpurpose"><span class="refname">Event::addTimer</span> &mdash; <span class="dc-title">Makes timer event pending</span></p>

 </div>
 <div class="refsect1 description" id="refsect1-event.addtimer-description">
  <h3 class="title">说明</h3>
  <div class="methodsynopsis dc-description">
   <span class="modifier">public</span>
   <span class="type">bool</span> 
   <span class="methodname"><strong>Event::addTimer</strong></span>
    ([ <span class="methodparam">
    <span class="type">double</span>
     <code class="parameter">$timeout</code>
   </span>
  ] )</div>

  <p class="para rdfs-comment">
   <span class="methodname"><strong>Event::addTimer()</strong></span>
   is an alias of
   <span class="methodname"><a href="event.add.html" class="methodname">Event::add()</a></span>
  </p>
 </div>

 <div class="refsect1 returnvalues" id="refsect1-event.addtimer-returnvalues">
  <h3 class="title">返回值</h3>
  <p class="para">
 </div>

 <div class="refsect1 examples" id="refsect1-event.addtimer-examples">
  <h3 class="title">范例</h3>
  <div class="example" id="example-4156">
   <p><strong>Example #1 
    <span class="function"><strong>Event::addTimer()</strong></span> example</strong></p>
   <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br />$base&nbsp;</span><span style="color: #007700">=&nbsp;new&nbsp;</span><span style="color: #0000BB">EventBase</span><span style="color: #007700">();<br /></span><span style="color: #0000BB">$n&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">2</span><span style="color: #007700">;<br /></span><span style="color: #0000BB">$e&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">Event</span><span style="color: #007700">::</span><span style="color: #0000BB">timer</span><span style="color: #007700">(</span><span style="color: #0000BB">$base</span><span style="color: #007700">,&nbsp;function(</span><span style="color: #0000BB">$n</span><span style="color: #007700">)&nbsp;use&nbsp;(&amp;</span><span style="color: #0000BB">$e</span><span style="color: #007700">)&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;echo&nbsp;</span><span style="color: #DD0000">"</span><span style="color: #0000BB">$n</span><span style="color: #DD0000">&nbsp;seconds&nbsp;elapsed\n"</span><span style="color: #007700">;<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$e</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">delTimer</span><span style="color: #007700">();<br />},&nbsp;</span><span style="color: #0000BB">$n</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$e</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">addTimer</span><span style="color: #007700">(</span><span style="color: #0000BB">$n</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$base</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">loop</span><span style="color: #007700">();<br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</code></div>
   </div>

   <div class="example-contents"><p>以上例程的输出类似于：</p></div>
   <div class="example-contents screen">
<div class="cdata"><pre>
2 seconds elapsed
</pre></div>
   </div>
  </div>
 </div>

 <div class="refsect1 seealso" id="refsect1-event.addtimer-seealso">
  <h3 class="title">参见</h3>
  <ul class="simplelist">
   <li class="member">
    <span class="methodname"><a href="event.add.html" class="methodname" rel="rdfs-seeAlso">Event::add()</a> - Makes event pending</span>
   </li>
   <li class="member">
    <span class="methodname"><a href="event.del.html" class="methodname" rel="rdfs-seeAlso">Event::del()</a> - Makes event non-pending</span>
   </li>
   <li class="member">
    <span class="methodname"><a href="event.deltimer.html" class="methodname" rel="rdfs-seeAlso">Event::delTimer()</a> - Makes timer event non-pending</span>
   </li>
  </ul>
 </div>

</div><hr /><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="event.addsignal.html">Event::addSignal</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="event.construct.html">Event::__construct</a></div>
 <div class="up"><a href="class.event.html">Event</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div></body></html>
